define(['require' , 'exports' , 'module' , 'jquery' , 'common/common' , 'layer' , 'baiduTemplate' ] ,
    function (require , exports , module , $ , common , layer) {

    var storelogin = function () {
        $('.form-submit').bind('click' , function () {
            var formData = {};
            $('.form-item').each(function(index , item){
                formData[$(item).attr('name')] = $(item).val();
            });

            common.ajaxPost('/store/login' , formData , function (error , data) {
                if(error == null && data.code == 0){
                    window.location.href = '/store/order';
                }else if(error == null){
                    layer.msg(data.msg);
                }
            });

        });
    };

    var changeStatus = function () {
        $('.change-status').bind('change' , function () {
            var __this = $(this);

            var postData = {
                o_id : __this.attr('o_id'),
                status : __this.val()
            };

            var layerLoad = layer.load(1, {
                shade: [0.1,'#fff'] //0.1透明度的白色背景
            });

            common.ajaxPost('/store/change/order/status' , postData , function (error , data) {
                if (error == null && data.code == 0) {
                    layer.msg('修改成功');
                } else if (error == null && data.code != 0) {
                    layer.alert(data.msg);
                } else {
                    layer.alert(error.statusText);
                }
                layer.close(layerLoad);
            });
        });
    };


    exports.changeStatus = changeStatus;
    exports.login = storelogin;

});
